<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
String pname=request.getParameter("username");
System.out.println(pname);
%>


<html>
  <head>
    <base href="<%=basePath%>">
<style type="text/css"> 
  html { height: 100% } 
  body { height: 100%; margin: 0px; padding: 0px } 
  #map_canvas { height: 100% } 
</style> 
<script type="text/javascript" 
    src="http://maps.google.com/maps/api/js?sensor=true"> </script>
<script type="text/javascript" >
    var map=null; 
	var gmarkers = []; 
function createXMLHttpRequest() {
	if (window.XMLHttpRequest) { //Mozilla 浏览器
		HttpReq = new XMLHttpRequest();
	} else if (window.ActiveXObject) { // IE浏览器
		HttpReq = new ActiveXObject("Microsoft.XMLHTTP");
	}
}
//发送请求函数
function sendRequest(url) {
	createXMLHttpRequest();
	HttpReq.open("GET", url, true);
	HttpReq.onreadystatechange = processResponse;//指定响应函数
	HttpReq.send(null); // 发送请求
}
// 处理返回信息函数
function processResponse() {
	if (HttpReq.readyState == 4) { // 判断对象状态
		if (HttpReq.status == 200) { // 信息已经成功返回，开始处理信息
			var data = HttpReq.responseText;
			//将数据显示在页面上   
		    var b = data.split("/");
		   // alert(b[0]);
			initialized(b[0], b[1]);
		} else { //页面不正常
			alert(HttpReq.status);
		}
	}
}

    //初始化地图
    function initialized(a,b) { 
   // alert(a);
    	var latlng = new google.maps.LatLng(b,a); 
    	var myOptions = { 
        zoom: 14, 
        center: latlng, 
        mapTypeId: google.maps.MapTypeId.ROADMAP 
    }; 
        map = new google.maps.Map(document.getElementById("map_canvas"), myOptions); 
        google.maps.event.addListener(map, 'click', function() {
  	    infowindow.close();
    });
        show1(b,a);
  } 
  //设置infowindow窗口大小
  var infowindow = new google.maps.InfoWindow(
  { 
    size: new google.maps.Size(150,50)
  });

  //显示marker
 function show1(a,b)
   {
		//var ss=<%=pname%>;
		var contentString = "<%=pname%>";
        var latlngs = new google.maps.LatLng(a,b);
        var marker = new google.maps.Marker({
			                         position:latlngs,
			                         map:map
			                        });
        google.maps.event.addListener(marker, 'click', function() {
        infowindow.setContent(contentString); 
        infowindow.open(map,marker);
        });
        gmarkers.push(marker);	  
		    
}
//marker单击事件
function myclick(i) {
  google.maps.event.trigger(gmarkers[i], "click");
}

function aa(bb){
    var uri = "guanyu?name=" + bb;
	uri = encodeURI(uri);
	uri = encodeURI(uri);
	sendRequest(uri);
}
</script>
  </head>
  
  <body onload="aa('<%=request.getParameter("username")%>')";>
    <table width="100%" border="1">
  <tr>
    <td><table>
          <tr>
			<td colspan="2">
		     <div id="map_canvas" style="width:830px; height:600px"></div> 
		    </td>
            <td>
			   
			  </td>
			</tr>
			</table>
		</td>
  </tr>
</table>
  </body>
</html>
